W32: Prefer the deadkey combinations that the OS uses
authorРуслан Ижбулатов <lrn1986@gmail.com>
Sat, 16 Jul 2016 09:23:22 +0000 (09:23 +0000)
committerРуслан Ижбулатов <lrn1986@gmail.com>
Thu, 4 Aug 2016 16:37:19 +0000 (16:37 +0000)
commit5e6c1928b4b45e34fd70d56f5cd229cfb2f30518
treef719e13320c3588525d6dc9a5ebeb5c84e30e593
parent52c7e07948f0d82ade7c730e99c53dea3e13ca67
W32: Prefer the deadkey combinations that the OS uses

Pick the W32 API for possible deadkey+<something> combinations
and prefer these to other sources of deadkey combos.
Specifically, if W32 API supports at least one combo for a particular
deadkey, only use that data and do not attempt to do other, unsupported
combinations, even if they make sense otherwise.
This is needed to, for example, correctly support US-International
keyboard layout, which produces a combined character for <' + a>
combo, but not for <' + s>, for example.

This is achieved by stashing all the deadkeys that we find in
an array, then doing extra loop through all virtual key codes and
trying to combine them with each of these deadkeys. Any combinations
that produce a single character are cached for later use.

In GTK Simple IM context, call a new GDK W32 function to do a lookup
on that cached combination table early on, among the "special cases"
(which are now partially obsolete).

A limitation of this code is that combinations with more than
one deadkey are not supported, except for combinations that consist
entirely of 2 known deadkeys. The upshot is that lookups should
be relatively fast, as deadkey array stays small and the combination
tree stays shallow.

Note that the use of ToUnicodeEx() seems suboptimal, as it should
be possible to just load a keyboard library (KBD*.DLL) manually
and obtain and use its key table directly. However, that is much more
complicated and would result in a significant rewrite of gdkkeys-win32.
The code from this commit, though hacky, is a direct addition to
existing code and should cover vast majority of the use-cases.

https://bugzilla.gnome.org/show_bug.cgi?id=569581
gdk/win32/gdkkeys-win32.c
gdk/win32/gdkwin32keys.h
gtk/gtkimcontextsimple.c